/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Principal;


import Gramatica.*;
import com.nilo.plaf.nimrod.NimRODLookAndFeel;
import com.nilo.plaf.nimrod.NimRODTheme;
import java.awt.Color;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import org.apache.log4j.PropertyConfigurator;


/**
 *
 * @author REI
 */
public class Principal extends javax.swing.JFrame {

    /**
     * Creates new form Principal
     */
    EditorTexto tab;
    String salida;
    File archivoaux;
    File archivonivel;
    File archivoenemigo;
    File archivojugador;
    Tabla tabla;
    Traductor traductor;
    ArrayList<String> temporales;
    public Principal() {
        
        setDefaultLookAndFeelDecorated(true);
        setBackground(Color.WHITE);
        try {

            NimRODTheme tema = new NimRODTheme("src/Temas/NimRODThemeFile1.theme");
            NimRODLookAndFeel milook = new NimRODLookAndFeel();

            NimRODLookAndFeel.setCurrentTheme(tema);
            UIManager.setLookAndFeel(milook);



        }catch (Exception e) {
            System.out.println(e);
        }
        initComponents();
        tabla = new Tabla();
        traductor = new Traductor();

    }
    
    public void AbrirArchivos()
    {
        boolean cargado = false;
        String[] patharchivo = null;
        JFileChooser choosercargar = new JFileChooser();
        choosercargar.setFileFilter(new Filtro("java", "archivo *.java"));



        choosercargar.showOpenDialog(this);


        if (choosercargar.getSelectedFile() != null) {
            salida = choosercargar.getSelectedFile().getAbsolutePath();
            File f = new File(salida);
            if (!f.exists()) {


                JOptionPane.showMessageDialog(null, "No Selecciono un Archivo");    //No existe
                } else {
                cargado = true;
                patharchivo = new String[2];
                patharchivo[0]=f.getName();
                patharchivo[1]=salida;
            }
        }// final del if

        if (cargado == true) {

            try {


                if (patharchivo != null && estaAbierto(patharchivo) ) {
                File archivo = null;
                BufferedReader entrada = null;
                String lectura = "";
                String contenido = "";
                archivo = new File(patharchivo[1].trim());
                contenido = "";
                if (archivo.getName().toLowerCase().endsWith(".java")) {
                    try {
                        entrada = new BufferedReader(new FileReader(archivo));
                    } catch (FileNotFoundException ex) {
                        System.out.println("no se puede leer el archivo");
                    }
                    try {
                        lectura = entrada.readLine();
                        while (lectura != null) {
                            contenido = contenido + lectura + "\n";
                            lectura = entrada.readLine();
                        }
                    } catch (IOException ex) {
                        System.out.println("fallo el buffer de lectura");
                    }


                      tab  = new EditorTexto();
                      tab.Inicializar(patharchivo[0],patharchivo[1], contenido);
                      tab.Analizar();
                      Tabbs.add(patharchivo[0], tab);
                      Tabbs.setSelectedIndex(Tabbs.getTabCount()-1);


                }

            }




            }catch (Exception ex) {
                ex.printStackTrace();

        }


        } else {

            
        }
    }
    
    public boolean estaAbierto(String[] path) {

        EditorTexto temp;
        String paths = "";
        for (int i = 0; i < Tabbs.getTabCount(); i++) {
            temp = (EditorTexto ) Tabbs.getComponentAt(i);
            paths = temp.getPath();
            if (paths.compareTo(path[1]) == 0) {
                Tabbs.setSelectedIndex(i);
                return false;
            }
        }
        return true;
    }
    
    public void GuardarArchivo(String path, String contenido) {
        File archivo = null;
        BufferedWriter escribir = null;

        try {
            archivo = new File(path);
            escribir = new BufferedWriter(new FileWriter(archivo));

            if (contenido != null) {
                escribir.write(contenido);

                }
            escribir.close();
        } catch (IOException ex) {
        }
    }
    
    public void Guardar()
    {
        if(Tabbs.getComponentCount()!=0)
         {
        EditorTexto aux = (EditorTexto)Tabbs.getComponentAt(Tabbs.getSelectedIndex());

         if(aux!=null)
         {
            GuardarArchivo(aux.getPath(), aux.getContenido());
         }
         }
    }
    
    public void Copiar()
    {
         if(Tabbs.getComponentCount()!=0)
         {
        EditorTexto aux = (EditorTexto)Tabbs.getComponentAt(Tabbs.getSelectedIndex());

         if(aux!=null)
         {
            aux.copiar();
         }
         
         }
    }
    
    public void Pegar()
    {
        if(Tabbs.getComponentCount()!=0)
         {
        EditorTexto aux = (EditorTexto)Tabbs.getComponentAt(Tabbs.getSelectedIndex());

         if(aux!=null)
         {
            aux.pegar();
         }
         }
    }
    
    public void GuardarComo()
    {
        if(Tabbs.getComponentCount()!=0)
         {
        String miarchivo;
        String ext;
        JFileChooser choosercargar = new JFileChooser();
        choosercargar.setFileFilter(new Filtro("java", "archivo *.java"));
        

        choosercargar.showSaveDialog(this);
        
        if (choosercargar.getSelectedFile() != null) {
            miarchivo = choosercargar.getSelectedFile().getAbsolutePath();

            ext = choosercargar.getFileFilter().getDescription();
            ext = ext.substring(ext.length()-5, ext.length());
            
            
            if(Tabbs.getComponentCount()!=0)
            {
                 EditorTexto aux = (EditorTexto)Tabbs.getComponentAt(Tabbs.getSelectedIndex());
                 if(aux!=null)
                 {
                    GuardarArchivo(miarchivo+ext, aux.getContenido());
                 }
            }
            
             
            
            
        }
        else
        {
             JOptionPane.showMessageDialog(null, "No Selecciono un Archivo");    //No existe
        }
        
        }
            
    }
    
    public File Abrir(String extension)
    {
        File archivo = null;
        String path;
        JFileChooser chooser = new JFileChooser();
        chooser.setFileFilter(new Filtro(extension,"archivo *."+extension));
        chooser.showOpenDialog(this);
        
        if(chooser.getSelectedFile()!=null)
        {
            path = chooser.getSelectedFile().getAbsolutePath();
            archivo = new File(path);
            if(archivo.exists())
            {
                return archivo;
            }
            else
            {
                return archivo;
            }
        }
        
        return archivo;
    }
    
    public void Compilar()
    {   if(Tabbs.getComponentCount()!=0)
         {
        PropertyConfigurator.configure("log4j.properties"); 
        EditorTexto aux = (EditorTexto)Tabbs.getComponentAt(Tabbs.getSelectedIndex());
        parser miparser;
        parserv miparser2;
        parserg3 miparser3;
        String content;
        File f;
        
         if(aux!=null)
         {
            f = new File(aux.getPath());
            try {
                miparser = new parser(new lex(new FileInputStream(f)));
                miparser.setDireccion(ObtenerPath(aux.getPath()));
                System.out.println(aux.getNombre());
                miparser.setNombre(aux.getNombre());
                miparser.parse();
                
                
                miparser2 = new parserv(new lexv(new FileInputStream(f)));
                miparser2.list = miparser.list;
                miparser2.var = miparser.var;
                
                miparser2.parse();
                
                tabla.setTabla(miparser.var.getDtm());
                

                if(miparser2.list.estaVacia())
                {
                   miparser3 = new parserg3(new lexg3(new FileInputStream(f)));
                   miparser3.list = miparser2.list;
                   miparser3.var = miparser2.var;
                   miparser3.setTabla();
                   miparser3.parse();
                   String nom = aux.getNombre().substring(0,aux.getNombre().length()-5);
                   System.out.println(nom);
                   temporales = new ArrayList<String>();
                   content = crearCodigoImports(ObtenerPath(aux.getPath()),miparser.var.getListaimports());
                   crearTemporales(miparser3.c3d.getTemporales());
                   content = codigoGlobal() + content + miparser3.salida;
                   miparser3.c3d.GuardarArchivo(miparser.direccion+nom+".ejecutable", content);
                   traductor.setVisible(true);
                }
                else
                {
                    JOptionPane.showMessageDialog(null,"Existe errores en el archivo compilado");
                try {
                        Process proceso = Runtime.getRuntime().exec("explorer Reporte Errores.html");
                    } catch (Exception eoli) {
                    }
                }
                
            } catch (FileNotFoundException ex) {
                Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
            } catch (Exception ex) {
                Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
            }
         }
         
         }
        
    }

    public void Analizar()
    {
        if(Tabbs.getComponentCount()!=0)
         {
        PropertyConfigurator.configure("log4j.properties");
        EditorTexto aux = (EditorTexto)Tabbs.getComponentAt(Tabbs.getSelectedIndex());
        analizador miparser;
        File f;
        Guardar();
         if(aux!=null)
         {
            f = new File(aux.getPath());
            try {
                miparser = new analizador(new FileInputStream(f));
                miparser.iniciar();


            } catch (FileNotFoundException ex) {
                Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
            } catch (Exception ex) {
                Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
            }
         }
         
         }

    }
    
    public String ObtenerPath(String dire)
    {
        String direccion="";
        String diraux;        
        diraux = dire.replace("\\", "//");
        String dir[];
        dir = diraux.split("//");
             
        for(int i=0; i < dir.length -1; i++)
        {
            direccion = direccion + dir[i] + "\\";
        }
        
        return direccion;
    }

    public void Codificar(boolean getter)
    {
        if(Tabbs.getComponentCount()!=0)
         {
        PropertyConfigurator.configure("log4j.properties");
        EditorTexto aux = (EditorTexto)Tabbs.getComponentAt(Tabbs.getSelectedIndex());
        parserf miparser;
        File f;
        Guardar();
         if(aux!=null)
         {
            f = new File(aux.getPath());
            try {
                miparser = new parserf(new lexf(new FileInputStream(f)));
                miparser.getter = getter;
                miparser.parse();  
                
                if(miparser.list.estaVacia())
                {
                    System.out.println(miparser.texto);
                    aux.jTextArea1.setText(miparser.texto);
                    aux.Analizar();
                }
                else
                {
                    System.out.println("hay errores");
                }

            } catch (FileNotFoundException ex) {
                Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
            } catch (Exception ex) {
                Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
            }
         }
         
         }

    }
    
    public String  crearCodigoImports(String direccion, ArrayList<String> importes)
    {
        String codigogenerado= "";
        String codigoimporte;
        
        for(String  importe: importes)
        {
            codigoimporte = generarCodigoImport(importe, direccion);
            codigogenerado = codigogenerado + codigoimporte;
        }
        
        
        
        return codigogenerado;
    }
    
    
    public String generarCodigoImport(String nombre, String direccion)
    {
        String escribir ="";
        
        PropertyConfigurator.configure("log4j.properties"); 
        
        parser miparser;
        parserv miparser2;
        parserg3 miparser3;
        File f;       
         
        f = new File(direccion+nombre+".java");
        try {
            miparser = new parser(new lex(new FileInputStream(f)));
            miparser.setDireccion(direccion);
            miparser.setNombre(nombre+".java");
            miparser.parse();


            miparser2 = new parserv(new lexv(new FileInputStream(f)));
            miparser2.list = miparser.list;
            miparser2.var = miparser.var;

            miparser2.parse();

//            tabla.setTabla(miparser.var.getDtm());


            if(miparser2.list.estaVacia())
            {
               miparser3 = new parserg3(new lexg3(new FileInputStream(f)));
               miparser3.list = miparser2.list;
               miparser3.var = miparser2.var;
               miparser3.setTabla();
               miparser3.parse();
               escribir = escribir + miparser3.salida;
               crearTemporales(miparser3.c3d.getTemporales());
                
            }

        } catch (FileNotFoundException ex) {
            Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
        }
         
         
         
        
        
                
        return escribir;        
    }

    public void crearTemporales(ArrayList<String> lista)
    {
        if(temporales!=null)
        {
            for(String temporal: lista)
            {
                if(!temporales.contains(temporal))
                {
                    temporales.add(temporal);
                }
            }
        }
    }
    
    public String codigoGlobal()
    {
         String escribir="";
        
         for(String temp1: temporales)
         {
             escribir = escribir + "int "+temp1+";\n";
         }
         escribir = escribir +"int pila[10000];\n";
         escribir = escribir +"int heap[10000];\n";
         escribir = escribir +"int p = 0;\n";
         escribir = escribir +"int h = 0;\n\n\n";
        
         return escribir;
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jToolBar1 = new javax.swing.JToolBar();
        btabrir = new javax.swing.JButton();
        btguardar = new javax.swing.JButton();
        btguardarcomo = new javax.swing.JButton();
        btcopiar = new javax.swing.JButton();
        btpegar = new javax.swing.JButton();
        btcompilar = new javax.swing.JButton();
        btformatear = new javax.swing.JButton();
        btgetter = new javax.swing.JButton();
        bttabla = new javax.swing.JButton();
        bteditor3d = new javax.swing.JButton();
        Tabbs = new javax.swing.JTabbedPane();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jToolBar1.setRollover(true);

        btabrir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/open.png"))); // NOI18N
        btabrir.setToolTipText("Abrir");
        btabrir.setFocusable(false);
        btabrir.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btabrir.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btabrir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btabrirActionPerformed(evt);
            }
        });
        jToolBar1.add(btabrir);

        btguardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/save.png"))); // NOI18N
        btguardar.setToolTipText("guardar");
        btguardar.setFocusable(false);
        btguardar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btguardar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btguardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btguardarActionPerformed(evt);
            }
        });
        jToolBar1.add(btguardar);

        btguardarcomo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/filesaveas.png"))); // NOI18N
        btguardarcomo.setToolTipText("Guardar Como..");
        btguardarcomo.setFocusable(false);
        btguardarcomo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btguardarcomo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btguardarcomo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btguardarcomoActionPerformed(evt);
            }
        });
        jToolBar1.add(btguardarcomo);

        btcopiar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/copy.png"))); // NOI18N
        btcopiar.setToolTipText("Copiar");
        btcopiar.setFocusable(false);
        btcopiar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btcopiar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btcopiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btcopiarActionPerformed(evt);
            }
        });
        jToolBar1.add(btcopiar);

        btpegar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/paste.png"))); // NOI18N
        btpegar.setToolTipText("Pegar");
        btpegar.setFocusable(false);
        btpegar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btpegar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btpegar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btpegarActionPerformed(evt);
            }
        });
        jToolBar1.add(btpegar);

        btcompilar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/compile.png"))); // NOI18N
        btcompilar.setToolTipText("compilar");
        btcompilar.setFocusable(false);
        btcompilar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btcompilar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btcompilar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btcompilarActionPerformed(evt);
            }
        });
        jToolBar1.add(btcompilar);

        btformatear.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/format.png"))); // NOI18N
        btformatear.setToolTipText("codificar");
        btformatear.setFocusable(false);
        btformatear.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btformatear.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btformatear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btformatearActionPerformed(evt);
            }
        });
        jToolBar1.add(btformatear);

        btgetter.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/getter.png"))); // NOI18N
        btgetter.setFocusable(false);
        btgetter.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btgetter.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btgetter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btgetterActionPerformed(evt);
            }
        });
        jToolBar1.add(btgetter);

        bttabla.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/table.png"))); // NOI18N
        bttabla.setToolTipText("mostrar tabla simbolos");
        bttabla.setFocusable(false);
        bttabla.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        bttabla.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        bttabla.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bttablaActionPerformed(evt);
            }
        });
        jToolBar1.add(bttabla);

        bteditor3d.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/editor.png"))); // NOI18N
        bteditor3d.setToolTipText("mostrar editor 3d");
        bteditor3d.setFocusable(false);
        bteditor3d.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        bteditor3d.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        bteditor3d.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bteditor3dActionPerformed(evt);
            }
        });
        jToolBar1.add(bteditor3d);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 1009, Short.MAX_VALUE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(Tabbs)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Tabbs, javax.swing.GroupLayout.DEFAULT_SIZE, 544, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Editor Texto", jPanel2);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 1024, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.TRAILING)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btpegarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btpegarActionPerformed
        // TODO add your handling code here:
        Pegar();
}//GEN-LAST:event_btpegarActionPerformed

    private void btcopiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btcopiarActionPerformed
        // TODO add your handling code here:
        Copiar();
}//GEN-LAST:event_btcopiarActionPerformed

    private void btguardarcomoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btguardarcomoActionPerformed
        // TODO add your handling code here:
        GuardarComo();
}//GEN-LAST:event_btguardarcomoActionPerformed

    private void btguardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btguardarActionPerformed
        // TODO add your handling code here:
        Guardar();
}//GEN-LAST:event_btguardarActionPerformed

    private void btabrirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btabrirActionPerformed
        // TODO add your handling code here:
        AbrirArchivos();
}//GEN-LAST:event_btabrirActionPerformed

    private void btcompilarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btcompilarActionPerformed
        // TODO add your handling code here:
        Guardar();
        Compilar();
    }//GEN-LAST:event_btcompilarActionPerformed

    private void btformatearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btformatearActionPerformed
        // TODO add your handling code here:
        Codificar(false);
        Guardar();
        
    }//GEN-LAST:event_btformatearActionPerformed

    private void btgetterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btgetterActionPerformed
        // TODO add your handling code here:
        Codificar(true);
        Guardar();
    }//GEN-LAST:event_btgetterActionPerformed

    private void bttablaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bttablaActionPerformed
        // TODO add your handling code here:
        tabla.setVisible(true);
    }//GEN-LAST:event_bttablaActionPerformed

    private void bteditor3dActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bteditor3dActionPerformed
        // TODO add your handling code here:
        traductor.setVisible(true);
    }//GEN-LAST:event_bteditor3dActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Principal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTabbedPane Tabbs;
    private javax.swing.JButton btabrir;
    private javax.swing.JButton btcompilar;
    private javax.swing.JButton btcopiar;
    private javax.swing.JButton bteditor3d;
    private javax.swing.JButton btformatear;
    private javax.swing.JButton btgetter;
    private javax.swing.JButton btguardar;
    private javax.swing.JButton btguardarcomo;
    private javax.swing.JButton btpegar;
    private javax.swing.JButton bttabla;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JToolBar jToolBar1;
    // End of variables declaration//GEN-END:variables
}
